<include file="public@header"/>

<link href="__TMPL__/public/assets/themes/{:cmf_get_admin_style()}/bootstrap.min.css" media="all" rel="stylesheet">
<style>
    @media print {
        a[href]:after {
            content: none !important;
        }
    }
</style>

<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li  class="active"><a href="{:url('Financial/refund')}">退费管理</a></li>
    </ul>
    <form class="well form-inline margin-top-20 row" method="post" action="{:url('Financial/refund')}">
        <label for="开始时间" class="col-lg-5 col-md-6 col-xs-12 form-group" style="margin-bottom: 15px;">
            退费日期:
            <input class="form-control" type="text" name="homework_starttime" style="" value="{:input('request.homework_starttime')}"
                   placeholder="年/月/日">
            -
            <input class="form-control" type="text" name="homework_endtime" style="" value="{:input('request.homework_endtime')}"
                   placeholder="年/月/日">
        </label>
        <label for="退费方式" class="col-lg-3 col-md-3 col-xs-6" style="margin-bottom: 15px;">
            退费方式:
            <select class="form-control"  name="way" class="way">
                <option value="0">全部</option>
                    <if condition="isset($param.way) && $param.way == 1">
                        <option value="1" selected>微信</option>
                        <else/>
                        <option value="1">微信</option>
                    </if>
                    <if condition="isset($param.way) && $param.way == 2">
                        <option value="2" selected>支付宝</option>
                        <else/>
                        <option value="2">支付宝</option>
                    </if>
                    <if condition="isset($param.way) && $param.way == 3">
                        <option value="3" selected>现金</option>
                        <else/>
                        <option value="3">现金</option>
                    </if>
                    <if condition="isset($param.way) && $param.way == 4">
                        <option value="4" selected>银行卡</option>
                        <else/>
                        <option value="4">银行卡</option>
                    </if>
                    <if condition="isset($param.way) && $param.way == 5">
                        <option value="5" selected>代金券</option>
                        <else/>
                        <option value="5">代金券</option>
                    </if>
            </select>
        </label>
        <label for="" class="col-lg-2 col-md-3 col-xs-6" style="margin-bottom: 15px;">
            状态:
            <select class="form-control"  name="status" class="status">
                <option value="0">全部</option>
                    <if condition="isset($param.status) && $param.status ==2">
                    <option value="2" selected>
                        已处理
                    </option>
                    <else/>
                    <option value="2">
                        已处理
                    </option>
                </if>
                <if condition="isset($param.status) && $param.status!=2 && $param.status!=0">
                    <option value="1" selected>
                        未处理
                    </option>
                    <else/>
                    <option value="1">
                        未处理
                    </option>
                </if>
            </select>
        </label>

        <label for="" class="col-lg-2 col-md-3 col-xs-6" >
            课程:
            <select class="form-control"  name="course_id" class="course_id">
                <option value="">选择课程</option>
                <foreach name="courses" item="vo">
                    <if condition="isset($param.course_id) && $param.course_id == $vo.id">
                        <option value="{$vo.id}" selected>
                            {$vo.course_name}
                        </option>
                        <else/>
                        <option value="{$vo.id}">
                            {$vo.course_name}
                        </option>
                    </if>
                </foreach>
            </select>
        </label>

        <label class="form-group col-lg-5 col-md-6 col-xs-9" style="margin-bottom:15px">
            校区-班级:
            <select class="form-control" name="school_id" id="school_id" style="width:179px;">
                <option value='0'>全部</option>
                <notempty name="schools">
                    <volist name="schools" id="vo">
                        <if condition="isset($param.school_id) && $param.school_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select> -
            <select class="form-control" name="class_id" id="class_id" style="width:179px;">
                <option value='0'>全部</option>
                <notempty name="classes">
                    <volist name="classes" id="vo">
                        <if condition="isset($param.class_id) && $param.class_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>
        </label>

        <label class="col-lg-4  col-md-3 col-offset-md-3 form-group" >
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Financial/refund')}">清空</a>
        </label>
    </form>

    <a class="btn btn-primary btn-sm print">打印列表</a>

    <form class="js-ajax-form printArea" action="" method="post">

        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>编号</th>
                <th>学员姓名</th>
                <th>学校</th>
                <th>班级</th>
                <th>课程</th>
                <th>退费原因</th>
                <th>退费方式</th>
                <th>退费金额(元)</th>
                <th>退费日期</th>
                <th>申请人</th>
                <th>经办人</th>
                <th>发票</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <notempty name="data">
                <foreach name="data" item="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.tname}</td>
                        <td>{$vo.sname}</td>
                        <td>{$vo.cname}</td>
                        <td>{$vo.ccname}</td>
                        <td>{$vo.content}</td>
                        <td>
                            <if condition="$vo.way eq 1">
                                微信
                            <elseif condition="$vo.way eq 2"/>
                                支付宝
                            <elseif condition="$vo.way eq 3"/>
                                现金
                            <elseif condition="$vo.way eq 4"/>
                                银行卡
                            <elseif condition="$vo.way eq 5"/>
                                代金券
                            <else/>
                            </if>
                        </td>
                        <td>{$vo.refuse_price}</td>
                        <td>{$vo.create_time|date='Y-m-d',###}</td>
                        <td>{$vo.napplicant}</td>
                        <td>{$vo.noperator}</td>
                        <td>
                            <if condition="isset($vo.bill_status) && $vo.bill_status eq 0">
                                不需要
                            <elseif if condition="$vo.status eq 1"/>
                                待开
                            <elseif if condition="$vo.status eq 2"/>
                                已开
                            </if>
                        </td>
                        <td>
                            <if condition="isset($vo.status) && $vo.status eq 1">
                                <span class="label label-warning">未处理</span>
                            <elseif if condition="isset($vo.status) && $vo.status eq 2"/>
                                <span class="label label-success">已处理</span>
                            </if>
                        </td>
                        <td>
                            <if condition="$vo.status eq 1">
                                <a href="{:url('Financial/refundHandle',array('id'=>$vo['id']))}" class="js-ajax-delete" data-msg="确定要退费吗？">退费</a> |
                                <a href="{:url('Financial/refundCancel',array('id'=>$vo['id']))}" class="js-ajax-delete" data-msg="确定要取消退费吗？">删除</a>
                            </if>
                        </td>
                    </tr>
                </foreach>
            </notempty>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </form>
</div>

<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/js/layer/layer.js"></script>
<script>
    $(function()
    {
        $('[name="homework_starttime"]').datepicker();
        $('[name="homework_endtime"]').datepicker();
        $('#homework_starttime').datepicker();
        $('#homework_endtime').datepicker();
    });

    //通过学校获取班级
    $('#school_id').on('change',function () {
        var sid = $(this).val();
        if(sid == 0){
            $('#class_id').empty();
            var html = '<option value=\"0\">全部</option>';
            $('#class_id').html(html);
            return false;
        }
        $.ajax({
            url:"{:url('Financial/ajax_class')}",
            type:'post',
            dataType:'json',
            data:{"school_id":sid},
            success:function(jsonData){
                $('#class_id').empty();
                var html = '<option value=\"0\">全部</option>';

                if(jsonData.code == 1){
                    for(var i in jsonData.data){
                        html += '<option value=\"'+jsonData.data[i].id+'\">'+jsonData.data[i].name+'</option>';
                    }
                }
                $('#class_id').html(html);
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
                console.log('xhr='+XMLHttpRequest.readyState+' status='+textStatus+' error='+errorThrown);
            }
        });
    });


    //打印功能
    $('body').on('click','.print',function () {
        var html = $(".printArea");
        printHtml(html.html());
    });

    function printHtml(html) {
        var bodyHtml = document.body.innerHTML;
        document.body.innerHTML = html;
        window.print();
        document.body.innerHTML = bodyHtml;
    }

</script>
</body>
